package com.changan.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changan.entity.User;
import com.changan.response.Result;
import com.changan.service.UserService;
import com.changan.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author xsy
 * @since 2021-08-26
 */
@Api(tags = "用户管理") //表示控制器类将要生成Api文档
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
        //分页查询用户
    @ApiOperation(value = "分页查询" ,notes = "介绍这个方法得作用")
    @GetMapping("/page")
        Result  page(){
        Page<User> page=new Page<>(1,3);
        Page<User> UserPage = userService.page(page);
        return Result.ok().data("UserPage",UserPage);
    }
    @ApiOperation(value = "分页加联表查询用户数据" ,notes = "传入页码及每页条数")
        @PostMapping("/findUserInnerDepart")
    public Result findUserInnerDepart(@RequestParam(value = "current",required = true,defaultValue = "1") Integer current,
                                      @RequestParam(value = "size",required = true,defaultValue = "5") Integer size,
                                      @RequestBody UserVo userVo){
        Page<User> page=new Page<>(current,size);
        Page<User> userPage = userService.findUserInnerDepart(page, userVo);
        return Result.ok().data("userPage",userPage);
    }

}

